package com.hpeng.daily.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.hpeng.daily.dao.AssetCardDao;
import com.hpeng.daily.service.AssetCardBookManager;
import com.hpeng.daily.service.AssetCardManager;
import com.hpeng.sys.model.AssetCard;
import com.hpeng.util.Pagination;

@Component("assetCardManager")
public class AssetCardManagerImpl implements AssetCardManager {
	@Resource
	private AssetCardDao assetCardDao;
	@Resource
	private AssetCardBookManager assetCardBookManager;
	
	public AssetCard addAssetCard(AssetCard assetCard,String oprtStstus,String operator,String operatename) {
		AssetCard ac = assetCardDao.save(assetCard);
		//assetCardBookManager.addAssetCardBook(ac,oprtStstus,operator,null,operatename);
		return ac;
	}

	public void deleteAssetCard(AssetCard assetCard,String oprtStstus,String operator,String operatename) {
		assetCardBookManager.addAssetCardBook(assetCard,oprtStstus,operator,null,operatename);
		assetCardDao.remove(assetCard.getAcid());
	}

	public void updateAssetCard(AssetCard assetCard,String oprtStstus,String operator,String idea,String operatename) {
		System.out.println("acManager-idea-->"+idea);
		AssetCard ac = assetCardDao.update(assetCard);
		assetCardBookManager.addAssetCardBook(ac,oprtStstus,operator,idea,operatename);
	}

	public Pagination<AssetCard> getPagination(int pageNumber, String[] hql,
			String order) {
		return assetCardDao.getPagination(pageNumber, hql, order);
	}

	public List<AssetCard> getAllAssetCard() {
		return assetCardDao.getAll();
	}

	public AssetCard findAssetCard(String acid) {
		return assetCardDao.get(acid);
	}

	public List<AssetCard> getAllAssetCardByCondition(String hql, String order) {	
		return assetCardDao.getByHql(hql+""+order);
	}

}
